package es.cazadoresmadridejos.util.model;

import java.util.Calendar;
import java.util.Date;

import es.cazadoresmadridejos.model.Reason;

public class ReasonUtil {

	public static Long getCurrentReason(){
		Integer year = Calendar.getInstance().get(Calendar.YEAR);
		Integer month = Calendar.getInstance().get(Calendar.MONTH);

		if(month >= 3){
			Integer nextYear = year + 1;
			year = (year * 10000) + nextYear;
		}else{
			Integer lastYear = year - 1;
			year = (lastYear * 10000) + year;
		}

		return Long.valueOf(year);
	}

	public static Long getReasonFromDate(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		Integer month = cal.get(Calendar.MONTH);

		Integer year = cal.get(Calendar.YEAR);

		if(month >= 3){
			Integer nextYear = year + 1;
			year = (year * 10000) + nextYear;
		}else{
			Integer lastYear = year - 1;
			year = (lastYear * 10000) + year;
		}

		return Long.valueOf(year);
	}
}
